package com.new4net.reactor;

public interface LockedEventHandler<T extends EventHolder> extends EventHandler<T>{
    @Override
    default void handle(T event) {
        Object lock = lockEvent(event);
        if(lock!=null){
            try {
                executeEvent(lock,event);
            }finally {
                unlockEvent(lock,event);
            }
        }
    }

    void unlockEvent(Object lock, T event);

    void executeEvent(Object lock,T event);

    boolean lockEvent( T event);
}
